﻿using Abp.Runtime.Session;
using Abp.Timing.Timezone;
using Mt.Site.Application.DataExporting.Excel.NPOI;
using Mt.Site.Application.Dto;
using Mt.Site.Application.Messages_.BackEnd.Dto;
using Mt.Site.Core.Storage;
using System;
using System.Collections.Generic;

namespace Mt.Site.Application.Messages_.BackEnd
{
    public class ExportMessageHelper: NpoiExcelExporterBase, IExportMessageHelper
    {
        public ExportMessageHelper(
          ITempFileCacheManager tempFileCacheManager)
          : base(tempFileCacheManager)
        {
           
        }
        public FileDto MessagesExportDataList(List<MessagesDto> ListDtos)
        {
            return CreateExcelPackage(
                "联系方式"+DateTime.Now+".xlsx",
                excelPackage =>
                {
                    var sheet = excelPackage.CreateSheet(L("Messages"));

                    AddHeader(
                        sheet,
                        "称呼",
                        L("AddedTime")
                        );

                    AddObjects(
                        sheet, 2, ListDtos,
                        _ => _.LoginName,
                        _ => _.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")
                        );

                    for (var i = 0; i < 11; i++)
                    {
                        sheet.AutoSizeColumn(i);
                    }
                });
        }

        public FileDto MessagesDownExportDataList(List<MessagesDto> ListDtos)
        {
            return CreateExcelPackage(
                "下载信息记录" + DateTime.Now + ".xlsx",
                excelPackage =>
                {
                    var sheet = excelPackage.CreateSheet(L("Messages"));

                    AddHeader(
                        sheet,
                        L("DownEmail"),
                        L("AddedTime")
                        );

                    AddObjects(
                        sheet, 2, ListDtos,
                        _ => _.EMail,
                        _ => _.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")
                        );

                    for (var i = 0; i < 11; i++)
                    {
                        sheet.AutoSizeColumn(i);
                    }
                });
        }
    }
}
